<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>el和data的不同写法</title>
    <script type="text/javascript" src="../js/vue.js"></script>
  </head>

  <body>
    <div id="root">
      <div>{{name}}</div>
      <div>{{age}}</div>
    </div>
    <script type="text/javascript">
      Vue.config.productionTip = false; //  关闭提示
      // 创建一个vue实例
      // 一个容器对应一个实例
      const vm = new Vue({
        // el: "#root", //element
        // data: {
        //   name: "小明",
        //   age: "18",
        // }, //data
        // data: function () {    简写为data()
        data() {
          console.log("@@@", this); //vue实例
          return {
            name: "小明",
            age: "18",
          };
        },
        methods: {
          //methods
        },
      });
      vm.$mount("#root");
    </script>
  </body>
</html>
